package com.dayu.finecomm.handler.cmd;

import io.netty.channel.ChannelHandlerContext;

import com.dayu.finecomm.protocol.SpecialCareChannelInboundAdapter;
import com.dayu.finecomm.protocol.pojo.TPacket;
import com.dayu.finecomm.source.ListenSource;

public final class CMDExtractHandler extends
		SpecialCareChannelInboundAdapter<TPacket> {

	final ListenSource source;

	public CMDExtractHandler(ListenSource source) {

		this.source = source;
	}

	@Override
	public void channelRead0(ChannelHandlerContext ctx, TPacket msg)
			throws Exception {

		if (msg.command != null) {

			msg.command.station = msg.id();
			ctx.fireChannelRead(msg.command);
		}

		ctx.fireChannelRead(msg);

	}
}